<?php
/*
 * 错误页面模块 2018-04-17
 * */
class errorpage_errorpage{
	public $G;
	public function __construct(&$G){
		$this->G = $G;
	}

	public function _init(){
		$this->dbpdo=$this->G->loadclass('dbpdo');
		$this->routes = $this->G->loadclass('routes');
		$this->tpl = $this->G->loadclass('tpl');
		$this->pages = $this->G->loadclass('pages');
	}
	
	public function curPageURL(){
		$pageURL = 'http';
		if ($_SERVER["HTTPS"] == "on"){
			$pageURL .= "s";
		}
		$pageURL .= "://"; 
		if ($_SERVER["SERVER_PORT"] != "80"){
			$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
		}else{
			$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
		}
		return $pageURL;
	}

	public function getList($Spage=1,$Snumber=PAGED,$condition="",$orderby='',$UrlStyle=""){
		$rs['data']=$this->dbpdo->query("errorpage",'*',$condition,"",$orderby,"",strval(intval($Spage-1)*$Snumber),$Snumber);
		$t=$this->dbpdo->query("errorpage",'count(*) AS total',$condition);
		$Intpages = $this->pages->set_page_info($t[0]['total'],$Snumber,$UrlStyle);
		if($rs['data']){
			$rs['pages']=$Intpages;
			$rs['total'] = $t[0]['total'];
			return $rs;
		}else{
			return false;
		}	
	}

	public function del($condition=array()){
		return $this->dbpdo->remove("errorpage",$condition);
	}

	public function getList301($Spage=1,$Snumber=PAGED,$condition="",$orderby='',$UrlStyle=""){
		$rs['data']=$this->dbpdo->query("errorpage_301",'*',$condition,"",$orderby,"",strval(intval($Spage-1)*$Snumber),$Snumber);
		$t=$this->dbpdo->query("errorpage_301",'count(*) AS total',$condition);
		$Intpages = $this->pages->set_page_info($t[0]['total'],$Snumber,$UrlStyle);
		if($rs['data']){
			$rs['pages']=$Intpages;
			$rs['total'] = $t[0]['total'];
			return $rs;
		}else{
			return false;
		}	
	}

	public function getOne301($condition=array()){
		return $this->dbpdo->getOne('errorpage_301','*',$condition);
	}

	public function add301($dsw){
		$this->dbpdo->insert_data('errorpage_301',$dsw);
	}

	public function update301($dsw,$condition=array()){
		$this->dbpdo->update_data('errorpage_301',$dsw,$condition);
	}

	public function del301($condition=array()){
		return $this->dbpdo->remove("errorpage_301",$condition);
	}
}
?>
